Skip to content

feat(JumpLinks): Animate scroll position based on selection#11800

Closed
rebeccaalpert wants to merge 1 commit intopatternfly:mainfrom
rebeccaalpert:jump-links
Closed

feat(JumpLinks): Animate scroll position based on selection#11800
rebeccaalpert wants to merge 1 commit intopatternfly:mainfrom
rebeccaalpert:jump-links

Conversation

@rebeccaalpert
Copy link
Copy Markdown
Member

@rebeccaalpert rebeccaalpert commented Apr 30, 2025

Refactored this to be able to handle smooth scrolling - had to drop prior logic that adjusted active item in scroll so scrolling doesn't update the active item. I did this to match main's behavior, but let me know if you want that as a fun extra. The targetTop logic is there to accommodate the last item in a list, which may not have sufficient scroll padding.

I'm less familiar with this component, so I would appreciate if someone could give this a look-over and let me know if I broke something that's less obvious.

What: Closes 11763

Additional issues:

@patternfly-build
Copy link
Copy Markdown
Collaborator

patternfly-build commented Apr 30, 2025

@rebeccaalpert rebeccaalpert requested review from a team, kmcfaul, srambach and wise-king-sullyman and removed request for a team April 30, 2025 18:06
@srambach
Copy link
Copy Markdown
Member

srambach commented May 6, 2025

I see the same behavior that I struggled with - if you click a link low on the page, and another above it but also low on the page, you can see that instead of smoothly scrolling up to the second link, it sort of jumps up further before sliding down a bit.
Maybe that's the best we can do - interested in design's opinion on whether the smooth scroll is worth it. @andrew-ronaldson

Also, it doesn't seem to respect my prefers-reduced-motion setting - without that I'd definitely hesitate to make this change. Here's an article that talks about how to use matchMedia to do this.

Copy link
Copy Markdown
Contributor

@kmcfaul kmcfaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've also noticed the scroll behavior is odd when on a lower item on the page and click a jump link to get higher on the page.

The code looks sounds but unsure if we want to let this go in with the animation quirks.

@andrew-ronaldson
Copy link
Copy Markdown
Collaborator

Agree with the comments above and thanks for tackling this issue @rebeccaalpert. The jumping back to the top before scrolling back down seems a bit odd. If there isn't a medium/easy fix I think we can hold this PR for the time being. There are other issues we can focus on.

@rebeccaalpert
Copy link
Copy Markdown
Member Author

Sounds good. I don't mind noodling a little bit more this week, but if I can't get it to play along I will close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Jump links - Animate scroll position based on selection

5 participants